<?php

namespace App\Models;

class FinanceTransferRecord extends Base
{
    /**
     * 状态: 转账中
     */
    const STATUS_TRANSFERRING = 1;

    /**
     * 状态: 已完成
     */
    const STATUS_COMPLETE = 2;

    /**
     * 状态: 转账失败
     */
    const STATUS_FAIL = 3;

    const STATUS_MAP = [
        self::STATUS_TRANSFERRING => '转账中',
        self::STATUS_COMPLETE => '已完成',
        self::STATUS_FAIL => '转账失败'
    ];

    /**
     * 目标类型: 一般对公户
     */
    const TARGET_TYPE_GENERALLY_FOR_PUBLIC_HOUSEHOLDS = 1;

    /**
     * 目标类型: 供应商
     */
    const TARGET_TYPE_SUPPLIER = 2;

    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
        'balance_snapshot' => 'array',
    ];

    /**
     * 拥有此转账的对象
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
     */
    public function subject()
    {
        return $this->morphTo();
    }
}
